/*
 * Filename:    IntegrityBlackDaoImpl.java
 * Copyright:   2014 中国平安保险（集团）股份有限公司 版权所有
 * Company:     平安科技养老险及健康险系统开发部
 * Create at:   2014年10月29日
 */
package com.paic.mhis.hcpms.trust.intergration.dao.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import com.paic.mhis.hcpms.trust.dto.BlackParamterCondtion;
import com.paic.mhis.hcpms.trust.dto.BlackPatientBaseInfoDTO;
import com.paic.mhis.hcpms.trust.dto.BlackResultAliasDTO;
import com.paic.mhis.hcpms.trust.dto.IntegrityAttentionIllegalDTO;
import com.paic.mhis.hcpms.trust.dto.IntegrityAttentionLevelDTO;
import com.paic.mhis.hcpms.trust.dto.IntegrityBlackDTO;
import com.paic.mhis.hcpms.trust.dto.IntegrityBlackOpinionDTO;
import com.paic.mhis.hcpms.trust.intergration.dao.IntegrityBlackDao;
import com.paic.pafa.biz.dao.BaseDAO;

@Component("integrityBlackDaoImpl")
public class IntegrityBlackDaoImpl extends BaseDAO implements IntegrityBlackDao {

	@Transactional
	@Override
	public void insertIntegrityBlackPerson(IntegrityBlackDTO bean) {

		this._insert("insertIntegrityBlackDTO", bean);

	}

	@Override
	public List<IntegrityBlackDTO> queryIntegrityBlackPerson(BlackParamterCondtion paramter) {

		List<IntegrityBlackDTO> list = (List<IntegrityBlackDTO>) this._queryForList("queryIntegrityBlackDTO", paramter);
		return list;
	}

	@Override
	public long queryIntegrityBlackCount(BlackParamterCondtion paramter) {

		long count = this._queryForCount("queryIntegrityBlackDTOCount", paramter);
		return count;
	}

	@Transactional
	@Override
	public void updateIntegrityBlackPerson(IntegrityBlackDTO bean) {
		this._insert("updateIntegrityBlackDTO", bean);
	}

	@Override
	public IntegrityBlackDTO getIntegrityBlackDTOBySocaitionNum(Map<String, Object> map) {

		List<IntegrityBlackDTO> list = (List<IntegrityBlackDTO>) this._queryForList(
				"queryIntegrityBlackDTOBySocaitionNum", map);
		if (list != null && list.size() > 0) {
			return list.get(0);
		} else {
			return null;
		}
	}

	@Override
	public IntegrityBlackDTO queryattentionMidIdCilck(Map<String, Object> map) {

		List<IntegrityBlackDTO> list = (List<IntegrityBlackDTO>) this._queryForList("queryattentionMidIdCilck", map);
		if (list != null && list.size() > 0) {
			return list.get(0);
		} else {
			return null;
		}
	}

	@Override
	public List<IntegrityBlackDTO> queryattentionMidIdCilckList(Map<String, Object> map) {

		return (List<IntegrityBlackDTO>) this._queryForList("queryattentionMidIdCilck", map);
	}

	@Override
	public List<IntegrityBlackDTO> loadAllIntegrityBlackPerson(BlackParamterCondtion parameter) {
		List<IntegrityBlackDTO> list = (List<IntegrityBlackDTO>) this._queryForList("loadAllIntegrityBlackDTO",
				parameter);
		return list;
	}

	/**
	 * 查询参保人信息
	 */
	public List<BlackPatientBaseInfoDTO> queryBlackPatientBaseInfoDTO(BlackParamterCondtion bean) {
		List<BlackPatientBaseInfoDTO> list = (List<BlackPatientBaseInfoDTO>) this._queryForList(
				"queryBlackPaientBaseInfo", bean);
		return list;
	}

	/**
	 * 查询参保人总记录数
	 */
	public long queryBlackPaientBaseInfoCount(BlackParamterCondtion bean) {
		long count = this._queryForCount("queryBlackPaientBaseInfoCount", bean);
		return count;
	}

	@Override
	public boolean checkBlackPaientBaseInfo(BlackParamterCondtion parameter) {
		long count = this._queryForCount("checkBlackPaientBaseInfo", parameter);
		if (count > 0) {
			return true;
		} else {
			return false;
		}
	}

	/**
	 * 查询所有的违规情节
	 */
	@Override
	public List<IntegrityAttentionIllegalDTO> queryAllIllegalInfo(Map<String, Object> map) {
		List<IntegrityAttentionIllegalDTO> list = (List<IntegrityAttentionIllegalDTO>) this._queryForList(
				"queryAllIllegalInfo", map);
		return list;
	}

	/**
	 * 查询所有的关注级别
	 */
	@Override
	public List<IntegrityAttentionLevelDTO> queryAllAttentionLevels(Map<String, Object> map) {

		List<IntegrityAttentionLevelDTO> list = (List<IntegrityAttentionLevelDTO>) this._queryForList(
				"queryAllAttentionLevels", map);
		return list;
	}

	/**
	 * 根据id加载对象
	 * 
	 * @param blackId
	 * @return
	 */
	@Override
	public IntegrityBlackDTO getIntegrityBlackDTOById(String blackId) {
		BlackParamterCondtion bean = new BlackParamterCondtion();
		bean.setBlackId(blackId);
		IntegrityBlackDTO obj = (IntegrityBlackDTO) this._queryForObject("getIntegrityBlackDTOById", bean);
		return obj;
	}

	@Transactional
	@Override
	public void updateAuditOpinion(IntegrityBlackOpinionDTO bean) {

		this._update("updateAuditBlackOpinion", bean);

	}

	@Override
	public IntegrityBlackOpinionDTO queryAuditOpinion(String blackId) {
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("blackId", blackId);
		IntegrityBlackOpinionDTO bean = (IntegrityBlackOpinionDTO) this._queryForObject("queryBlackAuditOpinion", map);
		return bean;
	}

	@Transactional
	@Override
	public void insertIntegrityBlackOpinionBean(IntegrityBlackOpinionDTO bean) {

		this._insert("addBlackAuditOpinion", bean);

	}

	@Override
	public long querySameParamPerson(String name, String cardNo, String cardType) {
		BlackParamterCondtion bean = new BlackParamterCondtion();
		bean.setCardNo(cardNo);
		bean.setName(name);
		bean.setPersonType(cardType);
		return (Long) _getObject("querySameParamPerson", bean);
	}

	@Override
	public String querySeqUploadNextval() {
		return _getString("querySeqUploadNextval", "");
	}

	@Override
	public List<BlackResultAliasDTO> queryBlackResultAlias() {
		return (List<BlackResultAliasDTO>) _list("queryBlackResultAlias", null);
	}

	@Override
	public List<Map<String, Object>> getCurrentSwiftNumber() {
		return (List<Map<String, Object>>) this._list("blackaudit.getCurrentSwiftNumber", "");
	}

	@Override
	public void updateCurrentSwiftNumber(Map<String, Object> paraMap) {
		
		this._update("blackaudit.updateCurrentSwiftNumber",paraMap);
	}
}
